class Compilation {
	//	Attributes
	String 	name
	String 	description
	String 	path
	boolean disabled	= false
	
	Date 	dateCreated
	Date 	lastUpdated
	
	static 	transients = ['rate']
	
	
	
	//	DB Relations
	static 	belongs = 	[createdBy:User]
	
	static 	hasMany = 	[comics:	Comic,
						 ratings:	Rate,
						 tags:		Tag]
					
	
	//	DB Constraits
	static 	constraints = {
		name(blank:false, unique:true, maxSize:50)
		description(nullable:true, maxSize:1000)
	}
	
	
	//	Default order to sort
	static mapping = {
		sort "name"
	}

	
	//	Other Methods
	String getRate() {
		//	Calculem la mitja de les puntuacions rebudes fins ara
		Float p = 0
		if(ratings){
			ratings.each(){ p += it.rate }
			p = p / ratings.count()
		}
		return p	//TODO: comprvar si esta linea hace falta
	}
}